home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Amiga-E
/
E_v3.2a_extras
/
PdSrc
/
Lang
/
Yax
/
pi.yax
< prev
next >
Wrap
Lisp/Scheme
|
1992-09-02
|
732b
|
43 lines
(defun pi (nr)
(set max (* nr 4))
(array a max)
(set m nr)
(for i 0 max (set (a i) 0))
(set k (- (/ (* m 3321) 1000) 1) )
(for n k 1
(set (a 0) (+ (a 0) 2))
(set p (+ 1 (* 2 n)))
(set c 0)
(for i 0 m
(set c (+ (* 10 c) (* n (a i))))
(set (a i) (/ c p))
(set c (- c (* (a i) p)))
)
(locate 5 20)
(write n ' ' '')
)
(for i m 1
(if (greater (a i) 9)
(do
(set (a i) (- (a i) 10) )
(set (a (- i 1)) (+ (a (- i 1)) 1))
)
)
)
(cls)
(write)
(write 'pi=3.' '')
(for i 1 m
(write (a i) '')
)
(write)
)
(window 0 11 400 150 'PI calc')
(write '#of decimals: ' '')
(set deci (readint))
(write 'busy ....')
(pi deci)
(write)